﻿using DA.Core.Common;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA.Core.Mes
{
    public class ClientManager
    {
        private Configurations configurations;
        private IContainerProvider containerProvider;
        private Dictionary<string,IClient> clientDics = new Dictionary<string, IClient>();

        public Dictionary<string, IClient> ClientDics
        {
            get { return clientDics; }
            set { clientDics = value; }
        }

        public ClientManager(IContainerProvider containerProvider, Configurations configurations)
        {
            this.configurations = configurations;
            this.containerProvider = containerProvider;
        }
        public void Init()
        {
            configurations?.Appsetting?.Mes.ForEach(p =>
            {
                var mes = containerProvider.Resolve<SocketClient>();
                mes.Connect(p.IpAddress, p.Port);
                clientDics.Add(p.MesID, mes);
            });
        }
    }
}
